<template>
  <div>
    <el-table
      :data="tableData"
      stripe
      style="width: 100%">
      <el-table-column
        prop="date"
        label="日期"
        width="180">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="180">
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址">
      </el-table-column>
    </el-table>
    <el-pagination
      background
      layout="sizes, prev, pager, next"
      :page-sizes="[5, 10, 20, 50]"
      :total="1000"
      align = 'right'
      @current-change = "goPage"
      @size-change = "goPageSize">
    </el-pagination>
  </div>
</template>

<script>

export default {
  name: 'dept',
  data () {
    return {
      tableData:[],
      pageSize:5,
      currentPage:1,
      total:0
    }
  },
  mounted() {
    this.loadAll()
  },
  methods:{
    goPage(currentPage){
      this.currentPage = currentPage;
      console.log('当前页码' + currentPage);
      this.loadAll();
    },
    goPageSize(pageSize){
      this.pageSize = pageSize;
      this.currentPage = 1;
      console.log('当前页码' + this.currentPage);
      console.log('每页展示条数' + pageSize);
      this.loadAll();
    },

    loadAll(){
      this.tableData = [{
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-04',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1517 弄'
      }, {
        date: '2016-05-01',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1519 弄'
      }, {
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1516 弄'
      }, {
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1516 弄'
      }, {
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1516 弄'
      }, {
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1516 弄'
      }, {
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1516 弄'
      }]
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
